package com.qf.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qf.mapper.RoleMapper;
import com.qf.pojo.QueryParams;
import com.qf.pojo.Role;
import com.qf.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Service
public class RoleServiceImpl implements RoleService {

    @Autowired
    private RoleMapper roleMapper;

    @Override
    public PageInfo<Role> findRoleAll(QueryParams params, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Role> list = roleMapper.findRoleAll(params);
        PageInfo<Role> pageInfo = new PageInfo<>(list,5);

        return pageInfo;
    }

    @Override
    @Transactional
    public int addRole(Role role) {
        return roleMapper.addRole(role);
    }

    @Override
    public Role findRoleOne(Integer roleId) {
        return roleMapper.findRoleOne(roleId);
    }

    @Override
    @Transactional
    public Integer updateRole(Role role) {
        return roleMapper.updateRole(role);
    }

    @Override
    public Integer deleteRole(Integer roleId) {
        return roleMapper.deleteRole(roleId);
    }
}
